package com.xs.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xs.pojo.Log;
import com.xs.service.LogSercice;
import com.xs.service.impl.LogSerciceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.BufferedReader;
import java.io.IOException;

@WebServlet("/selectByIdServlet")
public class SelectByIdServlet extends HttpServlet {
    LogSercice logSercice=new LogSerciceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //接收数据
        Integer id = Integer.parseInt(request.getParameter("id"));
        Log log = logSercice.SelectById(id);
        System.out.println("根据ID查询到的数据为:"+log);
        request.setAttribute("log",log);
        request.getRequestDispatcher("/update.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
